package com.tz.basedemo.basecode.baseUi.presenter;

import com.tz.basedemo.basecode.base.BaseBiz;
import com.tz.basedemo.basecode.baseUi.biz.DameActBiz;
import com.tz.basedemo.basecode.baseUi.contract.DameActContract;
import com.tz.basedemo.basecode.basebean.SelectVoiceInfo;
import com.tz.basedemo.bean.UserInfo;

import javax.inject.Inject;

/**
 * Created by Administrator on 2017/10/25.
 */

public class DameActPresenter implements DameActContract.MainPresenter {

    DameActContract.View view;
    DameActBiz dameActBiz;

    @Inject
    public DameActPresenter(DameActContract.View view) {
        this.view = view;
    }


    @Override
    public void setBiz(BaseBiz biz) {
        dameActBiz = (DameActBiz) biz;
    }


    @Override
    public void login() {
//        view.loading(true);
        dameActBiz.Login("9453eaa008524a665ac51c08e4d68273", "18120689985704", "XIAOFANG", "LEVEL_1", new BaseBiz.Callback<UserInfo>() {
            @Override
            public void onSuccess(UserInfo info) {
//                view.loading(false);
                System.out.println("UserInfo--->" + info.getUser().toString());
            }

            @Override
            public void onFailure(UserInfo info) {
//                view.loading(false);
            }
        });
    }


    @Override
    public void selectVoice() {
        view.loading(true);
        dameActBiz.selectVoice(view.curContext(), view.getSelectVoice(), new BaseBiz.Callback<SelectVoiceInfo>() {
            @Override
            public void onSuccess(SelectVoiceInfo o) {
                view.showSelectVoice(o);
                view.loading(false);
            }

            @Override
            public void onFailure(SelectVoiceInfo o) {
                view.showFalseSelectVoice();
                view.loading(false);
            }
        });
    }
}
